package com.chenyun.cocobackend.service;

import com.chenyun.cocobackend.entity.User;
import com.chenyun.cocobackend.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> select() {
        return userMapper.selectAll();
    }

    public boolean add(User user) {

        if (user.getId() == null) {
            return userMapper.insert(user);
        } else {
            return userMapper.update(user);
        }
    }

    public boolean update(User user) {
        return userMapper.update(user);
    }

    public boolean delete(Integer id) {
        return userMapper.deleteById(id);
    }
}
